/*
 *  (C) Copyright 2008 Insula Tecnologia da Informacao Ltda.
 * 
 *  This file is part of Vulcano.
 *
 *  Vulcano is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Vulcano is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Vulcano.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openinsula.vulcano.flex.example.controller;

import java.util.List;

import org.openinsula.vulcano.flex.controller.annotations.LazySafeController;
import org.openinsula.vulcano.flex.example.persistence.User;
import org.openinsula.vulcano.flex.util.ASUtils;
import org.openinsula.vulcano.orm.command.transaction.DaoCommandTransactionFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@LazySafeController
@Component
public class UserController {

	@Autowired
	private DaoCommandTransactionFacade transactionFacade;

	public List<User> listAllUsers() {
		return transactionFacade.listAll(User.class);
	}

	public User saveUser(final User user) {
		ASUtils.initialStateCheck(user);
		transactionFacade.save(user);
		return user;
	}

}
